-- shrine


function autoexec()
if (get_progress(P_QUEST1) >= 8) then 
  set_ent_active(0, 0)
end

return
refresh()
end


function postexec()

return
end


function zone_handler(zn)
  if (zn == 0) then
    if (get_progress(P_QUEST1) < 8) then 
      combat(51)
    end

  elseif (zn == 1) then
    change_map("land","shrine_exit");
    
  elseif (zn == 2) then --switch to open door to 2nd floor
    bubble(HERO1,"Hmm a switch. Here goes."); 
    sfx(25);
    set_btile("door1a", 47);
    set_ftile("door1b", 46);
    set_zone("door1b", 12);
    set_obs("door1b", 0);

  elseif (zn == 3) then
    book_talk(get_pidx(0));

  elseif (zn == 4) then
    bubble(HERO1,"Its Locked. Maybe we can find something around here that will open it.");

  elseif (zn == 5) then
    warp("1_up",8);

  elseif (zn == 6) then
    warp("2_dn",8);

  elseif (zn == 7) then
    bubble(HERO1,"There's nothing in there I want.");

  elseif (zn == 8) then
    chest(20, I_MHERB, 1)

  elseif (zn == 9) then
    bubble(HERO1,"I fear to know what is in this cauldron.");

  elseif (zn == 10) then
  --oven

  elseif (zn == 11) then
    bubble(HERO1,"Let's see what's behind this banner. Look a scroll!");
    bubble(HERO1,"In the seventh year of the reign of King Amalric the Terrible, King Amalric declared war on our small brotherhood in Diduma. He labeled us enemies to the peace.  We fled to this island of Thessalia before he could destroy us. Or so we thought. After ten years King Amalric decided that the brotherhood was stirring up the people of Diduma against him. Any fool would know the falseness of his claim. The only people on Thessalia besides the brotherhood are the strange sea people. The brotherhood had long before decided to abandon Diduma to its fate. Amalric sent his mightiest Mage General, Fiebraes the Bloodthirsty, to destroy our brotherhood. All were destroyed except for myself. I have spent the years since, delving into deep magics to free my brethren from death. One day we will rid this world of any remnant of Diduma.");
    bubble(HERO1,"I Moenach, the last survivor of the Brotherhood of Thessalia write this by my own hand.");
    bubble(HERO1,"..."); 
    bubble(HERO2,"Fiebraes... Corin that was your father...");
    msg("with barely concealed anger",255,0) 
    bubble(HERO1,"I am very aware of that!"); 

  elseif (zn == 12) then
  --opened door1

  elseif (zn == 13) then 
    chest(21, I_MHERB, 1)
    refresh()

  elseif (zn == 14) then
    chest(22, 0, 37)
    refresh()
    

  elseif (zn == 15) then
    bubble(HERO1,"It looks like some sort of statue."); 

  elseif (zn == 16) then
    bubble(HERO1,"Theres nothing in here that I could use.");

  elseif (zn == 17) then
    bubble(HERO1,"Theres a switch underneath this table. Here goes."); 
    sfx(25);
    set_btile("door2a", 47);
    set_ftile("door2b", 46);
    set_zone("door2b", 12);
    set_obs("door2b", 0);  

  elseif (zn == 18) then
    bubble(HERO1,"Theres nothing in here that I could use.");

  elseif (zn == 19) then
    bubble(HERO1,"Theres nothing in here that I could use.");

  elseif (zn == 20) then
    bubble(HERO1,"Theres nothing in here that I could use.");  

  elseif (zn == 21) then
    warp("1_dn",8);

  elseif (zn == 22) then
    warp("base_up",8);

  elseif (zn == 23) then   
    bubble(HERO1,"Theres nothing left.");  

  elseif (zn == 24) then   
    chest(24, 0, 103); 
    refresh();

  elseif (zn == 25) then   
    chest(23, I_OSEED, 1);  
    set_zone("chest5", 3);




 end
end

function entity_handler(en)
  if (en == 0) then
    bubble(HERO1,"You have something we need.");
    bubble(en,"You shall never get it from me! Your attempts are in vain. Diduma will never rise again!"); 
    bubble(HERO1,"I $0 the Fierce challenge you for it.");
    bubble(HERO2,"And I $1 the Brave.");
    bubble(en,"Muhahaha The son of my enemy walks right up to me. I would have gladly slaughtered your father, $0. But alas I hear we are a little too late for that. Muhahaha");
    msg("Corin screams in rage",255,0);
    bubble(HERO1,"Enough talk!");
    bubble(en,"That is true. It is now time to avenge my brothers. RISE MY BROTHERS!");
    drawmap()
    screen_dump()
    set_run(0)
    combat(52);
    set_run(1)
    if (get_alldead() == 1) then
      return
    end
    set_progress(P_QUEST1, 8)
    refresh()
    set_ent_active(0, 0)
    drawmap()
    screen_dump()  
    bubble(HERO1,"Ah finally thats done with.");
    bubble(HERO2,"Yeah your telling me."); 
    bubble(HERO1,"And I just found the other key piece.");
    sfx(5) 
    msg("Key piece procurred!",255,0) 
    bubble(HERO2,"Excellent lets get back to the Capital."); 
    bubble(HERO1,"Yeah.");
  end  
      

  end




function refresh()
      
 if (get_treasure(21) == 1) then
    set_ftile("chest2", 61)
    set_zone("chest2", 23)
  end 

if (get_treasure(22) == 1) then
    set_ftile("chest3", 61)
    set_zone("chest3", 23)
  end 

if (get_treasure(24) == 1) then
    set_ftile("chest4", 61)
    set_zone("chest4", 23)
  end 

  return
end

